package com.chunfeng.mypen.controller;

import com.chunfeng.mypen.entity.TopicRecoding;
import com.chunfeng.mypen.result.JsonRequest;
import com.chunfeng.mypen.service.TopicRecodingService;
import com.chunfeng.mypen.vo.TopicRecodingVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: 做题历史记录控制层
 * @author: 小雷
 * @createTime: 2023-11-14 00:25:45
 */
@RestController
@RequestMapping("/topicRecoding")
@Api(value = "题目历史控制层", tags = "题目历史访问操作接口")
public class TopicRecodingController {
    @Autowired
    private TopicRecodingService topicRecodingService;

    /**
     * 条件查询所有试卷
     *
     * @param topicRecoding 题目历史实体类，包含所有查询条件
     * @return
     */
    @GetMapping
    @ApiOperation(value = "分类筛选题目历史信息")
    public JsonRequest<List<TopicRecodingVo>> lookTopicRecoding(
            @ApiParam(value = "试卷信息", required = true)
            TopicRecoding topicRecoding) {
        return topicRecodingService.lookTopicRecoding(topicRecoding);
    }

    /**
     * 添加题目历史信息
     *
     * @param topicRecoding 需要添加的实体类
     * @return
     */
    @PostMapping
    @ApiOperation(value = "添加题目历史信息")
    public JsonRequest<Integer> addTopicRecoding(
            @ApiParam(value = "添加的题目历史信息", required = true)
            @RequestBody TopicRecoding topicRecoding) {
        return topicRecodingService.addTopicRecoding(topicRecoding);
    }

    /**
     * 修改题目历史信息
     *
     * @param topicRecoding 需要修改的实体类
     * @return
     */
    @PutMapping
    @ApiOperation(value = "修改题目历史信息")
    public JsonRequest<Integer> updateTopicRecoding(
            @ApiParam(value = "修改的题目历史信息", required = true)
            @RequestBody TopicRecoding topicRecoding) {
        return topicRecodingService.updateTopicRecoding(topicRecoding);
    }

    /**
     * 删除题目历史信息
     *
     * @param ids 需要删除的题目历史id
     * @return
     */
    @DeleteMapping
    @ApiOperation(value = "删除题目历史")
    public JsonRequest<Integer> deleteTopicRecoding(
            @ApiParam(value = "删除题目历史的id", required = true)
            @RequestBody List<String> ids) {
        return topicRecodingService.deleteTopicRecoding(ids);
    }
}
